﻿<%@ Page Language="C#" AutoEventWireup="true" Codebehind="ListResponsibility.aspx.cs"
    Inherits="LabMS.Web.LabPersonnel.ListResponsibility" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>人员岗位职责列表</title>
    <link type="text/css" rel="stylesheet" href="../style/screen.css" />
    <!--[if lte IE 6]>
    <link type="text/css" rel="stylesheet" href="../style/ie6.css" />
    <![endif]-->
    <!--[if lte IE 7]>
    <link type="text/css" rel="stylesheet" href="../style/ie7.css" />
    <![endif]-->

    <script type="text/javascript" src="../../js/Common.js"></script>

</head>
<body class="mainBody">
    <form id="form1" runat="server">
        <div class="main">
            <div id="pageInfo" class="clearfix">
                <div class="title">
                    <label>
                        人员岗位职责列表</label>
                </div>
            </div>
        </div>
        <div class="main">
            <p>
                <%--<asp:CheckBox ID="checkall" runat="server" Font-Size="9pt" Text="全选" />--%>
                <input id="btAddRespons" type="button" onclick="RedirectURL(window, 'AddResponsibility.aspx')"
                    value="添加" class="button" />
                <asp:Button ID="DeleteBtn" Text="删除" runat="server" OnClick="Delete_OnClick" CssClass="button" />
            </p>
            <p>
                查询列<asp:DropDownList ID="ddlResKeyColum" runat="server">
                    <asp:ListItem Text="岗位职责名称" Value="Resp_Name"></asp:ListItem>
                    <asp:ListItem Text="职责内容" Value="Resp_Content"></asp:ListItem>
                    <asp:ListItem Text="实验室名称" Value="Resp_Lab"></asp:ListItem>
                </asp:DropDownList>关键字<asp:TextBox ID="tbResKeyWord" runat="server"></asp:TextBox>
                <asp:Button ID="btSearch" CssClass="button" runat="server" Text="搜索" OnClick="btSearch_Click" />
            </p>
        </div>
        <div class="main">
            <asp:GridView ID="gvResponsList" AutoGenerateColumns="false" AllowPaging="true" Width="100%"
                PageSize="5" DataKeyNames="ID" OnPageIndexChanging="GridViewRespons_PageIndexChanging"
                OnRowDataBound="GridViewRespons_RowDataBound" runat="server" CssClass="infoTable">
                <Columns>
                    <asp:TemplateField ItemStyle-CssClass="checkBox">
                        <HeaderTemplate>
                            <asp:CheckBox ID="CBAll" runat="server" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="ResponsCB" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="Resp_Name" HeaderText="岗位职责名称" />
                    <asp:BoundField DataField="Resp_Content" HeaderText="职责内容" />
                    <asp:BoundField DataField="Lab_Name" HeaderText="实验室名称" />
                </Columns>
                <HeaderStyle CssClass="header" />
                <EmptyDataTemplate>
                    没有数据！
                </EmptyDataTemplate>
            </asp:GridView>
        </div>
    </form>

    <script type="text/javascript" src="../js/jQuery/jquery-1.3.1.js"></script>

    <script type="text/javascript">

        $(function(){
            /* 修改样式 */
            $("#gvResponsList > tbody > tr:even").not(":first").addClass("even");
            $("#gvResponsList > tbody > tr").not(":first")
                .hover(
                    function(){
                        $(this).addClass("hover");
                    },
                    function(){
                        $(this).removeClass("hover");
                });

            /* 全选 */
            $("#gvResponsList > tbody > tr:first :checkbox").click(function(){
                if ($(this).attr("checked")){
                    $("#gvResponsList :checkbox").attr("checked", "checked");
                    cbChanged();
                } else{
                    $("#gvResponsList :checkbox").attr("checked", "");
                    cbChanged();
                }
            });

            /* Checkbox事件 */
            $("#gvResponsList :checkbox").not(":first").click(cbChanged);

            $("#DeleteBtn").click(function(e){
                if (!confirm('您确认要删除所选人员?')) {
                    e.preventDefault();
                }
            });

            cbChanged();
        });

        /* 检测Checkbox的选择状态，更改button的disabled属性 */
        function cbChanged(){
            var hasChecked = false;
            var allChecked = true;
            $("#gvResponsList :checkbox").not(":first").each(function(index, domEle){
                var curChecked = $(domEle).attr("checked");
                if (!hasChecked && curChecked){
                    hasChecked = true;
                }

                allChecked &= curChecked;
            });

            if (hasChecked){
                $("#DeleteBtn").attr("disabled", "");
            } else {
                $("#DeleteBtn").attr("disabled", "disabled");
            }

            if (allChecked){
                $("#gvResponsList :checkbox").filter(":first").attr("checked", "checked");
            } else {
                $("#gvResponsList :checkbox").filter(":first").attr("checked", "");
            }
        }

    </script>

</body>
</html>
